package nc.hdysc.engine.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import nc.bs.dao.BaseDAO;
import nc.bs.dao.DAOException;
import nc.hdysc.engine.itf.IFieldEscape;
import nc.jdbc.framework.processor.ColumnProcessor;
import nc.jdbc.framework.processor.MapListProcessor;
import nc.vo.hdysc.engine.SyncTaskBVO;

public class EnumFieldEscapeImpl implements IFieldEscape {
	
	// xx:1,yy:2##0
	public List<Object> getArguList(String arguString) {
		List<Object> arguList = new ArrayList<Object>();
		String[] arguArray = arguString.split("##");
		for (String argu : arguArray) {
			arguList.add(argu);
		}
		return arguList;
	}
	
	public Object getEscapeValue(BaseDAO dao,SyncTaskBVO fieldEscapeConf, Map<String, Object> orginalVO) {
		List<Object> arguList = getArguList(fieldEscapeConf.getArgus());
		int result = Integer.parseInt(arguList.get(1).toString());
		String enums = arguList.get(0).toString();
		for (String enumItem : enums.split(",")) {
			String enumKey = enumItem.split(":")[0];
			//int enumValue = Integer.parseInt(enumItem.split(":")[1]);
			String escapeFieldName = fieldEscapeConf.getS_field().toString().toLowerCase();
			if(enumKey.equals(orginalVO.get(escapeFieldName).toString())){
				 result = Integer.parseInt(enumItem.split(":")[1]);
			}
		}
		return result;
	}

	


	

}
